<template>
	<view class="regest_member">
		<view>
			<h3 style="text-align: center;">您不是VIP, 请选择升级</h3>
		</view>
		<view class="upgrade-vip">
			<uni-card>
				<view><text>登录用户名: {{curUserInfo.memberCode}}</text></view>
				<view><text>姓名: {{curUserInfo.realName}}</text></view>
				<view><text>手机号: {{curUserInfo.mobile}}</text></view>
			</uni-card>
			<uni-forms ref="form" :rules="formRules">
				<uni-forms-item required label="真实姓名" name="realName">
					<uni-easyinput type="text" v-model="registInfo.member.realName" placeholder="请输入真实姓名" />
				</uni-forms-item>
				<uni-forms-item required label="VIP资格" name="joinLevel">
					<uni-data-picker :localdata="JoinLevelList" popup-title="请选择VIP级别"
						v-model="registInfo.member.lastJoinLevel" @change="onchangeLevel">
					</uni-data-picker>
				</uni-forms-item>
				<uni-forms-item required label="身份证号" name="idCard">
					<uni-easyinput type="text" v-model="registInfo.member.idCard" placeholder="请输入身份证" />
				</uni-forms-item>
				<uni-forms-item required label="性别" name="gender">
					<uni-data-checkbox v-model="registInfo.member.gender" :localdata="genderData">
					</uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item required label="分享编号" name="introducerCode">
					<uni-easyinput type="text" :disabled="true" v-model="registInfo.member.introducerCode"
						 />
				</uni-forms-item>
<!-- @blur="onCompleteIntroCode()" -->
				<!-- <uni-forms-item v-if="!firstIntro&&!curUserInfo.parentCode" label="推荐AB区最低层服务编号">
					<uni-data-checkbox :localdata="AB_last_code" @change="setParentCode">
					</uni-data-checkbox>
				</uni-forms-item> -->

				<uni-forms-item required label="服务编号" name="parentCode">
					<uni-easyinput type="text" v-model="registInfo.member.parentCode" />
				</uni-forms-item>
				<uni-forms-item required label="区域服务商编号" name="serviceCode">
<!-- 					<uni-easyinput type="text" v-model="registInfo.orders.serviceCode" placeholder="可以根据分享编号自动获取" />
 -->					<uni-data-picker :localdata="serviceCodeList" popup-title="可以根据分享编号自动获取" :class="disabled_serviceCode===true?'disabled':''"
						v-model="registInfo.orders.serviceCode">
						<!-- <uni-easyinput type="text" :disabled="true" v-model="registInfo.orders.serviceCodeTest"
							 /> -->
					</uni-data-picker>
				</uni-forms-item>

				<uni-forms-item required label="收货省份" name="c_province">
					<uni-data-picker :localdata="provinceData" popup-title="请选择收货省份"
						v-model="registInfo.orders.consigneeProvinceId" @change="onchangeProvince">
					</uni-data-picker>
				</uni-forms-item>
				<uni-forms-item required label="收货城市" name="c_city">
					<uni-data-picker :localdata="cityData" popup-title="请选择收货城市"
						v-model="registInfo.orders.consigneeCityId" @change="onchangeCity">
					</uni-data-picker>
				</uni-forms-item>
				<uni-forms-item required label="收货区县" name="c_district">
					<uni-data-picker :localdata="districtData" popup-title="请选择收货区县"
						v-model="registInfo.orders.consigneeDistrictId">
					</uni-data-picker>
				</uni-forms-item>
				<uni-forms-item required label="收货地址" name="address">
					<uni-easyinput type="text" v-model="registInfo.orders.consigneeAddress" placeholder="请输入收货地址" />
				</uni-forms-item>
				<uni-forms-item required label="收货人" name="consignee">
					<uni-easyinput type="text" v-model="registInfo.orders.consigneeName" placeholder="请输入收货人" />
				</uni-forms-item>
				<uni-forms-item required label="收货电话" name="mobile">
					<uni-easyinput type="text" v-model="registInfo.orders.consigneeMobile" placeholder="请输入收货电话" />
				</uni-forms-item>

			</uni-forms>
			<!-- <button @click="submit">Submit</button> -->
		</view>

		<view class="product_lsit">
			<ul style="background: #F5F5F5;">
				<li v-for="list in productList" :key="list.id">
					<p>
						<span>{{ list.PACKAGE_NAME }}</span><span v-if="list.IS_OVERSEAS === 1" class="haitao">海淘</span>
					</p>
					<view class="shangpin_img_fuqin">
						<img :src="imageName(list)" class="shangpin_img">
					</view>
					<view class="sign_list">
						<span class="identifying ident">产品编号</span>
						<span class="identifying">{{ list.PACKAGE_CODE }}</span>
					</view>
					<p v-if="list.PACKAGE_NAME.includes('维特酪蛋白葡聚糖压片糖果')">
						<span style="text-decoration:line-through; color: #8B0000;">原价: {{ list.PRICE * 2 }}</span>
					</p>
					<view class="sign_list">
						<span class="identifying ident">价格</span>
						<span class="identifying">{{ list.PRICE }}</span>
						<span class="identifying">, pv: {{ list.PV }}</span>
					</view>
					<view class="sign_list">
						<view class="shaopp_pv">
							<span class="identifying ident">金额</span>
							<span class="identifying">{{ list.PRICE * list.num }}</span>
						</view>
						<view class="shappong_btn">
							<image src="/static/images/subtract.png" class="subtract" @click="subtract(list)"></image>
							<input v-model="list.num" style="font-size: .3rem;" class="product_num" type="text"
								readonly>
							<image src="/static/images/append.png" class="append" @click="append(list)"></image>
						</view>
						<!-- <view class="shappong_btn">
								<uni-number-box @change="changeProductCount(list)" v-model="list.num"  ></uni-number-box>
							</view> -->
					</view>
					<view v-if="list.IS_PRESALE == 1" class="stock-info">
						{{list.PRESALE_TIPS}}
					</view>
				</li>
			</ul>
		</view>
		<!-- <mt-field v-if="show_IdCard_box" label="身份证" v-model="order_idCard"
        :attr="{ oninput: 'if(value.length>18)value=value.slice(0,18)' }"
        @blur.native.capture="h5CheckIdCardNull(order_idCard)"
      /> -->
		<view class="footerBtn">
			<view class="footerBtn_list_money right_border">
				<p>总金额: {{ TotalAmount }} </p>
				<p>, 总PV: {{ TotalPV }}</p>
			</view>
			<view class="footerBtn_list" @click="sendPost">提交</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		IMG_URL,
	} from '@/config/app_member.js';
	import {
		getRegionListByParent,
		checkServiceCode,
		getPackageData,
		submitUpgradeVip,
		checkMemberCode,
		getServiceCode,
		checkIsFirstIntroOrder,
		getIntroducerLastLayer,
		getMemberInfo,
		getUpgradeToCoding
	}
	from '@/api/directSelling.js';
	import {
		parseTime
	} from '@/utils/util.js'
	export default {
		components: {
			// 'v-header': Header
		},
		data() {
			return {
				curUserInfo: null,
				firstIntro: true,
				AB_last_code: [],
				serviceCodeList:[],
				JoinLevelList: [{
						value: 2,
						text: 'VIP - ¥1500(pv1200)'
					},
					{
						value: 12,
						text: '黄金VIP - ¥4500(pv3600)'
					},
					{
						value: 22,
						text: '钻石VIP - ¥10500(pv8400)'
					},
					{
						value: 32,
						text: '至尊VIP - ¥21000(pv16800)'
					},
				],
				genderData: [{
					"value": "1",
					"text": "男"
				}, {
					"value": "2",
					"text": "女"
				}],
				formRules: {
					realName: {
						rules: [{
							required: true,
							errorMessage: '请填写真实姓名',
						}]
					},
					joinLevel: {
						rules: [{
							required: true,
							errorMessage: '请选择级别',
						}, ]
					},
					idCard: {
						rules: [{
								required: true,
								errorMessage: '请输入身份证号',
							},
							{
								errorMessage: '身份证号码格式不正确',
								pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
							},
							{
								validateFunction: async function(rule, value, data, callback) {
									let result = true
									var str2 = value;
									var year = str2.slice(6, 10);
									var month = str2.slice(10, 12);
									var date = str2.slice(12, 14);
									let bir=`${year}-${month}-${date}`;
									let nowYear=new Date().getFullYear();
									let nowMonth=new Date().getMonth() + 1;
									let nowDate=new Date().getDate();
									if(nowMonth<10){
										nowMonth="0"+nowMonth;
									}
									if(nowDate<10){
										nowDate="0"+nowDate;
									}
									result = false;
									if(nowYear-year>18){
										result = true;
									}else if(nowYear-year==18){
										//  13112220040109342X
										if(nowMonth<month){
											result = false
										}else{
											if(nowMonth=month){
												if(nowDate<date){
													result = false
												}else{
													result=true;
												}
											}else{
												result=true;
											}
										}
									}else{
										result = false
									}
									console.log("result=====");
									console.log(result);
									return result;
								},
								errorMessage: '注册会员年龄须大于18岁',
							},
						]
					},
					gender: {
						rules: [{
							required: true,
							errorMessage: '请选择性别',
						}]
					},
					introducerCode: {
						rules: [{
								required: true,
								errorMessage: '请填写分享编号',
							},
							{
								validateFunction: async function(rule, value, data, callback) {
									let result = false
									await checkMemberCode(value).then(res => {
										result = res.meta.success
									})
									return result
								},
								errorMessage: '分享编号不存在',
							},
							{
								validateFunction: function(rule, value, data, callback) {
									let curUserInfo = uni.getStorageSync('userInfo')
									// console.log(curUserInfo)
									if (curUserInfo.introducerCode == '') {
										return true
									} else {
										return curUserInfo.introducerCode == value
									}
								},
								errorMessage: '分享编号不能修改',
							}
						]
					},
					parentCode: {
						rules: [{
								required: true,
								errorMessage: '请填写服务编号',
							},
							{
								validateFunction: async function(rule, value, data, callback) {
									let result = false
									await checkMemberCode(value).then(res => {
										result = res.meta.success
									})
									return result
								},
								errorMessage: '服务编号不存在',
							},
							// {
							// 	validateFunction: function(rule, value, data, callback) {
							// 		let curUserInfo = uni.getStorageSync('userInfo')
							// 		// console.log(curUserInfo)
							// 		if (curUserInfo.parentCode == null) {
							// 			return true
							// 		} else {
							// 			return curUserInfo.parentCode == value
							// 		}
							// 	},
							// 	errorMessage: '服务编号不能修改',
							// }
						]
					},
					serviceCode: {
						rules: [{
								required: true,
								errorMessage: '请填写服务中心编号',
							},
							{
								validateFunction: async function(rule, value, data, callback) {
									console.log('区域服务商编号测试');
									console.log(value);
									let result = false
									await checkMemberCode(value).then(res => {
										result = res.meta.success && res.data.isService === 1
									})
									return result
								},
								errorMessage: '服务中心不存在',
							}
						]
					},
					c_province: {
						rules: [{
							required: true,
							errorMessage: '请选择收货省份',
						}, ]
					},
					c_city: {
						rules: [{
							required: true,
							errorMessage: '请选择收货城市',
						}, ]
					},
					c_district: {
						rules: [{
							required: true,
							errorMessage: '请选择收货区县',
						}, ]
					},
					address: {
						rules: [{
							required: true,
							errorMessage: '请填写收货地址',
						}]
					},
					consignee: {
						rules: [{
							required: true,
							errorMessage: '请填写收货人',
						}]
					},
					mobile: {
						rules: [{
								required: true,
								errorMessage: '请填写收货手机号',
							},
							{
								errorMessage: '手机格式不正确',
								pattern: /^1[3456789]\d{9}$/
							}
						]
					}
				},
				provinceData: [],
				cityData: [],
				districtData: [],
				curProvinceId: 0,
				curCityId: 0,
				curDistrictId: 0,
				changeCount: 0,
				show_realname: null,
				mobile_number_fist: null,
				recInfo: null,
				introducerCode_name: '', // 推荐人姓名
				parentCode_name: '', // 安置人姓名
				joinlevelList: null,
				releasePass: false,
				show_Flag: false,
				edit_user_code: false,
				isweek: false,
				title: '',
				birthday: null,
				pickerPopup: false,
				par: {
					A: false,
					B: false
				},
				amount: '',
				symbol: null,
				registInfo: {
					member: {
						lastJoinLevel: 2, //加盟级别
						countryId: 1, // 会员国家ID
						province: 0,
						city: 0,
						district: 0,
						memberCode: null, // 会员编号
						realName: null, // 会员姓名找国家发货中心
						mobile: null, // 会员手机号
						idCardType: 1, // 证件类型 1 身份证
						idCard: '', // 证件号码 唯一 必填
						gender: null, // 会员性别
						email: '', // 会员邮箱
						birthday: '1995-12-12', // 会员生日
						address: '', // 会员地址
						introducerCode: null, // 会员推荐人编号
						parentCode: '', // 会员安置人编号
					},
					// memberBank: {},
					orders: {
						serviceCode: null, // 发货中心编号
						consigneeCountryId: 1, // 收货国家ID
						consigneeProvinceId: null, // 收货人省份ID
						consigneeCityId: null, // 收货人城市ID
						consigneeDistrictId: null, // 收货人区县ID
						consigneeAddress: null, // 收货人地址
						consigneeName: null, // 收货人姓名
						consigneeMobile: null, // 收货人电话
						serviceCode: null, // 发货中心编号
						idCard: '',
						serviceCodeTest:null,
					},
					packageInfo: null,
					orderTotalAmounts: 0
				},

				show_realname: null,
				CountryIdList: [], // 国家
				ProvinceIdList: [], // 省份
				CityIdList: [],
				DistrictIdList: [],
				hasDistrictIdList: true,
				hasCityIdList: true,
				title: '',
				TotalAmount: 0,
				TotalPV: 0,
				searchValue: '',
				product_num: 1,
				productList: [],
				packageTypeList: '',
				countryId: '',
				searchId: '0',
				// oldProductList: '',
				sendPostDate: [],
				moneyArray: [],
				isCfk: '0',
				isCfkCountry: false,
				isSelectCfk: false,
				isDisable: false,
				show_IdCard_box: false,
				order_idCard: null,
				disabled_serviceCode: false
			}
		},
		onReady() {

		},
		onBackPress(options) {
			let self = this;
			if (options.from === 'navigateBack') {
				return false;
			}
			uni.switchTab({
				url: "/pages/index/index",
				animationType: 'none',
				animationDuration: 0,
				fail(err) {
					uni.redirectTo({
						url: "/pages/index/index"
					})
				}
			})
			return true;
		},
		created() {
			this.curUserInfo = uni.getStorageSync('userInfo');
			//this.registInfo.member.realName = this.curUserInfo.realName;
			this.registInfo.member.province = this.registInfo.orders.consigneeProvinceId;
			this.registInfo.member.city = this.registInfo.orders.consigneeCityId;
			this.registInfo.member.district = this.registInfo.orders.consigneeDistrictId;
			getUpgradeToCoding().then(res => {
				let data = res.data;
				if(res.meta.success==true){
					this.registInfo.member.introducerCode = data.introducerCode;
					this.registInfo.member.parentCode = data.parentCode;
					if (data.introducerCode) {
						this.onCompleteIntroCode();
					}
				}
			})
			// this.plh_parentCode_placeholder = this.RegestNewMember.plh_parentCode_name
			this.getProvinceData()

			//产品
			this.countryId = 1
			this.getPackageList()

		},
		mounted() {
			this.title = '升级VIP'
			this.$mount()
			this.isDisable = false
		},
		methods: {
			onCompleteIntroCode() {
				this.getParentCodes()
				this.getServiceCode_()
			},
			getParentCodes() {
				checkIsFirstIntroOrder(this.registInfo.member.introducerCode).then(res => {
					// console.log('checkIsFirstIntroOrder: ', res)
					if (!res.data.memberCode) {
						this.firstIntro = false

						console.log('不是首单')
						this.AB_last_code = []
						getIntroducerLastLayer(this.registInfo.member.introducerCode).then(res => {
							// console.log(res)
							if (res.data.A) {
								this.AB_last_code.push({
									text: 'A区: ' + res.data.A.memberCode,
									value: res.data.A.memberCode
								})
							}
							if (res.data.B) {
								this.AB_last_code.push({
									text: 'B区: ' + res.data.B.memberCode,
									value: res.data.B.memberCode
								})
							}
						})
						// this.registInfo.member.parentCode = res.data.memberCode
					} else {
						this.firstIntro = true
					}
				})
			},
			setParentCode(e) {
				// console.log(e)
				this.registInfo.member.parentCode = e.detail.value
			},
			getServiceCode_() {
				getServiceCode(this.registInfo.member.introducerCode).then(res => {
					this.serviceCodeList=[];
					this.registInfo.orders.serviceCode="";
					this.disabled_serviceCode=false;
					if(res){
						let data= res.data;
						data.forEach((ele)=>{
							this.serviceCodeList.push({
								"text": ele.memberCode + '-' + ele.realName,
								"value": ele.memberCode
							})
						})
						if(data.length==1) {
							this.registInfo.orders.serviceCode = res.data[0].memberCode;
							this.disabled_serviceCode=true;
						}
					}
				})
			},
			getProvinceData() {
				getRegionListByParent(1).then(res => {
					let mData = res.data.map((e) => {
						return {
							"text": e.regionName,
							"value": e.regionId
						}
					})
					// console.log(mData)
					this.provinceData = mData
				}).catch((err) => {
					console.log("判断是否报错");
					console.log(err);
				})
			},
			onchangeProvince(e) {
				if (e) {
					this.cityData = []
					this.districtData = []
					this.curProvinceId = e.detail.value[0].value
					getRegionListByParent(this.curProvinceId).then(res => {
						let mData = res.data.map((e) => {
							return {
								"text": e.regionName,
								"value": e.regionId
							}
						})
						this.cityData = mData
					})
				}
			},
			onchangeCity(e) {
				this.curCityId = e.detail.value[0].value
				getRegionListByParent(this.curCityId).then(res => {
					let mData = res.data.map((e) => {
						return {
							"text": e.regionName,
							"value": e.regionId
						}
					})
					this.districtData = mData
				})
			},

			onchangeLevel(e) {
				const value = e.detail.id
			},

			ageGt() {
				// console.log(judgeAge(this.registInfo.member.birthday))
				console.log(this.registInfo.member.birthday)
				this.registInfo.member.birthday = parseTime(this.registInfo.member.birthday, '{y}-{m}-{d}')
				this.pickerPopup = false
				if (!judgeAge(this.registInfo.member.birthday)) {
					uni.showToast({
						title: '注册会员年龄须大于18岁',
						icon: 'error',
						duration: 2000
					})
				}
			},
			checkParentPlace(parentCode) {
				this.$axios.post('/shop_member/h5new/checkRelationWhileRegister?parentCode=' + parentCode)
					.then(res => {
						if (res.data.meta.success === false) {
							this.releasePass = false
						}
					})
			},
			parentCode($event) {
				this.checkParentPlace($event.target.value)
				this.yan_parentCode_name($event.target.value)
			},
			async yan_parentCode_name(value) {
				const memberCode = value
				const result = await this.getMemberByCode(memberCode)
				console.log(result)
				if (result) {
					if (result.data.meta.success) {
						this.parentCode_name = result.data.data.realName
						this.releasePass = true
					} else {
						this.releasePass = false
					}
				}
			},
			// 获取查找会员信息
			getMemberByCode(memberCode, type) {
				if (this.recInfo) {
					return this.$axios.get('/shop_member/h5new/getMemberByCodeCheckSameCountry?memberCode=' + memberCode +
						'&recm=' + this.recInfo.recm).catch(res => {
						if (res.data.meta.success) {
							this.releasePass = true
						}
					})
				}
				return this.$axios.get('/shop_member/h5/getMemberByCode?memberCode=' + memberCode).catch(res => {
					if (res.data.meta.success === false) {
						this.releasePass = false
					}
				})
			},
			// 校验用户名是否被注册
			h5CheckMemberCodeNull(memberCode) {
				return this.$axios.get('/shop_member/h5new/h5CheckMemberCodeNull?memberCode=' + memberCode).then(res => {
					if (res.data.meta.success) {
						return true
					} else {
						return false
					}
				})
			},
			// 校验密码是否合法
			h5CheckIdPasswordNull(password) {
				return this.$axios.get('/shop_member/h5new/h5CheckIdPasswordNull?password=' + password).then(res => {
					if (res.data.meta.success) {
						return true
					} else {
						return false
					}
				})
			},
			// 校验手机号是否被注册
			h5CheckMobileNull(mobile) {
				if (mobile) {
					if (!this.checkMobile(mobile)) {
						uni.showToast({
							title: '手机号格式不正确', // '注册会员年龄须大于18岁',
							icon: 'error',
							duration: 2000
						})
						return false
					} else {
						return true
					}
				} else {
					uni.showToast({
						title: '请输入手机号', // '注册会员年龄须大于18岁',
						icon: 'error',
						duration: 2000
					})
				}
			},
			// 校验身份证是否被注册
			// 校验身份证是否被注册
			h5CheckIdCardNull(IdCard) {
				if (!this.checkIDCard(IdCard)) {
					uni.showToast({
						title: '身份证号格式错误',
						icon: 'error',
						duration: 2000
					})
					return false
				}
				var str2 = IdCard
				var year = str2.slice(6, 10)
				var month = str2.slice(10, 12) - 1
				var date = str2.slice(12, 14)
				console.log(month)
				var time1 = new Date(year, month, date)
				this.registInfo.member.birthday = parseTime(time1, '{y}-{m}-{d}')
				this.registInfo.member.birthday = time1
				if (!judgeAge(this.registInfo.member.birthday)) {
					uni.showToast({
						message: '注册会员年龄须大于18岁',
						icon: 'error',
						duration: 2000
					})
					return false
				} else {
					return true
				}
			},
			// 验证服务中心是否存在
			h5CheckRealPlacecodeNull(serviceCode) {
				return checkServiceCode(serviceCode).then(res => {
					if (res.data.meta.success) {
						console.log(res.data)
						this.show_realname = res.data.data.realName
						return true
					} else {
						return false
					}
				})
			},
			// 校验接点人是否在推荐人的体系下
			checkParentCode() {
				const introducerCode = '&introducerCode=' + this.registInfo.member.introducerCode
				const parentCode = '&parentCode=' + this.registInfo.member.parentCode
				const parms = introducerCode + parentCode
				return this.$axios.get('/shop_member/h5/checkParentCode?' + parms).then(res => {
					if (res.data.meta.success) {
						return true
					}
				})
			},
			// 校验手机格式
			checkMobile(mobile) {
				return RegExp(/^1[3456789]\d{9}$/).test(mobile)
			},

			sendPost() {

				this.registInfo.member.memberCode = this.curUserInfo.memberCode
				//this.registInfo.member.realName = this.curUserInfo.realName
				this.registInfo.member.mobile = this.curUserInfo.mobile
				this.registInfo.member.province = this.registInfo.orders.consigneeProvinceId
				this.registInfo.member.city = this.registInfo.orders.consigneeCityId
				this.registInfo.member.district = this.registInfo.orders.consigneeDistrictId
				this.registInfo.member.address = this.registInfo.orders.consigneeAddress

				//设置生日
				var str2 = this.registInfo.member.idCard
				var year = str2.slice(6, 10)
				var month = str2.slice(10, 12) - 1
				var date = str2.slice(12, 14)
				var time1 = new Date(year, month, date)
				this.registInfo.member.birthday = parseTime(time1, '{y}-{m}-{d}')

				this.registInfo.packageInfo = this.sendPostDate
				this.registInfo.orderTotalAmounts = this.TotalAmount


				this.$refs.form.validate().then(res => {
					console.log('表单数据信息：', res);
					//let json = JSON.stringify(this.registInfo)
					//console.log(json)
					submitUpgradeVip(this.registInfo).then(res => {
						if (res.meta.success == true) {
							let data = res.data;
							if (data) {
								uni.navigateTo({
									url: '/pages/users/order_confirm/orderDetails1?orderId=' +
										data +
										"&saleType=1"
								})
							}
						}

					})

				}).catch(err => {
					console.log('表单错误信息：', err);
				})

			},
			subtract(items) {
				if (items.num === 0) {
					return false
				} else {
					for (let index = 0; index < this.sendPostDate.length; index++) {
						if (this.sendPostDate[index].packageId === items.ID) {
							items.num--
							this.sendPostDate[index].purchaseQty--
							this.moneyArray[index].TotalAmount = items.num * items.PRICE
							this.moneyArray[index].TotalPV = items.num * items.PV
							if (this.sendPostDate[index].purchaseQty === 0) {
								this.sendPostDate.splice(index, 1)
								this.moneyArray.splice(index, 1)
							}
						}
					}
					this.TotalAmount = 0
					this.TotalPV = 0
					for (const item of this.moneyArray) {
						this.TotalAmount += item.TotalAmount
						this.TotalPV += item.TotalPV
					}
				}
				this.orderTotalAmounts = this.TotalAmount
				// this.show_IdCard()
			},

			append(items) {
				let count = 0
				if (items.num === 0) {
					if (items.PACKAGE_NAME.includes('赠品') && items.num >= 1) {
						return
					}
					items.num++
					this.sendPostDate.push({
						packageId: items.ID,
						purchaseQty: items.num
					})
					this.moneyArray.push({
						packageId: items.ID,
						purchaseQty: items.num,
						PRICE: items.PRICE,
						PV: items.PV,
						TotalAmount: items.num * items.PRICE,
						TotalPV: items.num * items.PV
					})
				} else {
					for (let index = 0; index < this.sendPostDate.length; index++) {
						if (this.sendPostDate[index].packageId === items.ID && !items.PACKAGE_NAME.includes('赠品')) {
							items.num++
							this.sendPostDate[index].purchaseQty++
							this.moneyArray[index].purchaseQty++
							this.moneyArray[index].TotalAmount = (items.num * items.PRICE)
							this.moneyArray[index].TotalPV = items.num * items.PV
						}
					}
				}
				this.TotalAmount = 0
				this.TotalPV = 0
				for (const item of this.moneyArray) {
					this.TotalAmount += item.TotalAmount
					this.TotalPV += item.TotalPV
				}
				this.orderTotalAmounts = this.TotalAmount
				// this.show_IdCard()
			},
			/* 为了处理身份证输入框显示与否 */
			show_IdCard() {
				for (const i in this.productList) {
					if (this.productList[i].IS_OVERSEAS) {
						if (this.productList[i].IS_OVERSEAS === 1 && this.productList[i].num > 0) {
							this.show_IdCard_box = false
							return
						} else {
							this.show_IdCard_box = false
						}
					}
				}
			},
			imageName(agrs) {
				if (agrs) {
					return IMG_URL + '/productPackage_mall/' + agrs.ID + '/' + agrs.IMAGE_NAME
				} else {
					// return require('@/assets/img/faile.png')
				}
			},
			// 产品列表
			getPackageList() {
				getPackageData(31).then(res => {
					if (res) {
						for (var i in res.data) {
							res.data[i].num = 0
						}
						this.productList = res.data
					}
				})
			},
		},

	}
</script>

<style scoped lang="scss">
	body,
	page {
		background: #fff;
	}

	.upgrade-vip {
		padding: 30rpx;
	}

	.shangpin_img_fuqin {
		width: 150rpx;
		height: 150rpx;
		position: relative;

		.shangpin_img {
			width: 100%;
			height: 100%;
		}
	}

	//   view{
	//     box-sizing: border-box;
	//   }
	// .regest_member {
	.footerBtn {
		width: 100%;
		height: 50px;
		border-top: 1px solid #dedede;
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		background: #fff;
		color: #158ED0;

		.footerBtn_list_money {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			width: 66%;
			padding-left: 0.4rem;
		}

		.footerBtn_list {
			width: 33%;
			justify-content: center;
			align-items: center;
			display: inline-flex;
			flex-wrap: wrap;

			p {
				display: inline-flex;
				font-size: .28rem;
				width: 100%;
				color: #333333;
				justify-content: center;
			}
		}

		.right_border {
			border-right: 1px solid #E5E5E5;
		}
	}

	//   .meberlist {
	//     margin-top: 1rem;
	//     margin-bottom: 1rem;
	//     .mt-progress {
	//       height: 0px;
	//     }
	//     .server_box {
	//       width: 100%;
	//       display: flex;
	//       flex-direction: row;
	//       justify-content: space-between;
	//       align-items: center;
	//       .server_box_realname {
	//         width: 50%;
	//         text-align: center;
	//         font-size: 0.3rem;
	//       }
	//     }
	//     .meber_info {
	//       margin-top: 3px;
	//       padding-bottom: 1.1rem;
	//       .mint-field {
	//         // border-bottom: 1px solid #f0f0f0;
	//       }
	//       /deep/ .mint-cell-text:before {
	//         content: '* ';
	//         color: red;
	//       }
	//       .selsctIput {
	//         width: 100%;
	//         height: 48px;
	//         display: flex;
	//         padding-left: 10px;
	//         padding-right: 10px;
	//         box-sizing: border-box;
	//         justify-content: left;
	//         align-items: center;
	//         // border-bottom: 1px solid #f0f0f0;
	//         span {
	//           width: 105px;
	//           font-size: 0.3rem;
	//           display: inline-flex;
	//           //  font-weight: 700;
	//         }
	//         span:before {
	//           width: 12px;
	//           content: '*';
	//           color: red;
	//         }
	//         select {
	//           width: 100%;
	//           -webkit-box-flex: 1;
	//           -ms-flex: 1;
	//           flex: 1;
	//           display: flex;
	//           outline: none;
	//           height: 0.70rem;
	//           // border: 1px solid #999;
	//           word-break: break-all;
	//           white-space: normal;
	//           font-size: 0.3rem;
	//           option {
	//             width: 100%;
	//             word-break: break-all;
	//             white-space: normal;
	//           }
	//         }
	//       }
	//     }

	ul {
		padding: 0;
		margin: 0;
		margin-bottom: 130rpx;
	}

	.product_lsit li {
		// float:left; 
		list-style: none;
		width: 100%;
		/* height: 210px; */
		padding: 20px;
		background: #fff;
		margin-bottom: 10px;
		box-sizing: border-box;

		p {
			font-size: 28rpx;
			font-weight: bold;
			margin-bottom: 10px;
		}

		.haitao {
			display: inline-block;
			width: 0.5rem !important;
			height: 0.3rem !important;
			line-height: 0.3rem;
			border-radius: 0.04rem;
			font-size: 0.2rem;
			color: #FFFFFF;
			background: linear-gradient(90deg, #ec2d1b, #fc4f27) !important;
			margin-left: 0.2rem;
			text-align: center;
		}

		.sign_list {
			display: flex;
			height: 27px;
			align-items: center;
			margin-top: 0.3rem;

			.identifying {
				font-size: 26rpx;
				display: inline-flex;

			}

			.ident {
				width: 100px;
			}

			.shaopp_pv {
				display: inline-flex;
			}

			.shappong_btn {
				display: inline-flex;
				height: 25px;
				width: 80%;
				align-content: center;
				justify-content: flex-end;
				;

				.subtract,
				.append {
					display: inline-flex;
					justify-content: center;
					align-items: center;
					font-size: 0.7rem;
					padding: 0 15px;
					height: 34rpx;
					width: 104rpx;
				}

				.product_num {
					height: 18px;
					width: 40px;
					align-items: center;
					display: inline-flex;
					outline: transparent;
					text-align: center;
					border: 1px solid #e5e5e5;
					border-radius: 1;
					-webkit-appearance: none; //  ios默认去除内阴影
					-webkit-tap-highlight-color: #fff;
				}
			}
		}

		.extra_slign {
			// border-bottom: 1px solid #E5E5E5;
			padding-bottom: 10px;
			margin-bottom: 5px;
		}
	}
	
	.disabled {
		pointer-events: none;
		background: #F7F7F7;
		color:#D5D5D5;
	}
	//   }
	// }
</style>
